#ifndef COLORBUTTONPAGE_H
#define COLORBUTTONPAGE_H

#include <QWidget>
#include <QPushButton>
#include <QGridLayout>
#include <QVector>

class ColorButtonPage : public QWidget
{
    Q_OBJECT

public:
    explicit ColorButtonPage(QWidget *parent = nullptr);
    void resetGame();

private slots:
    void onColorButtonClicked();
    void onGridButtonClicked();
    void returnToMain();

private:
    void createColorButtons();
    void createGameGrid();
    void floodFill(int row, int col, QColor originalColor, QColor newColor);
    bool isValidPosition(int row, int col);
    void checkWinCondition();

    QGridLayout *mainLayout;
    QGridLayout *gameGridLayout;
    QVector<QVector<QPushButton*>> gameGrid;
    QPushButton *selectedColorButton;
    int gridSize = 8;
    QList<QColor> colorPalette;
};

#endif // COLORBUTTONPAGE_H
